<template>
  <div class="base">
    <!-- 头像和预览 -->
    <div class="base-avatar">
      <UploadAvatar/>
      <div class="preview">
        <PreviewImage :imgUrl="$store.state.userModule.userInfo.avatar" />
      </div>
    </div>
    <!-- 基本信息列表 -->
    <div class="base-list">
      <AdminItem v-if="userInfo.role===0" :user="userInfo"/>
      <TeacherItem v-else-if="userInfo.role===1" :user="userInfo"/>
      <StudentItem v-else :user="userInfo"/>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex'
import UploadAvatar from '@/components/UpdateAvatar/UploadAvatar.vue'
import PreviewImage from '@/components/PreviewImage'
import AdminItem from './ListItem/AdminItem.vue'
import TeacherItem from './ListItem/TeacherItem.vue'
import StudentItem from './ListItem/StudentItem.vue'

const store = useStore()

const userInfo = computed(() => store.state.userModule.userInfo)

</script>

<style lang="less" scoped>
.base {
  width: 100%;
  height: 100%;
  .base-avatar {
    position: relative;
    height: 110px;
    text-align: center;
    border-bottom: 1px solid #eee;
    .preview {
      position: absolute;
      top: 45px;
      right: 1px;
    }
  }
  .base-list {
    width: 100%;
    height: 100%;
  }
}
li {
  list-style: none;
}
</style>
